package com.xingyu.springbootlearn.controller;

import com.xingyu.springbootlearn.mapper.DepartmentMapper;
import com.xingyu.springbootlearn.pojo.Department;
import com.xingyu.springbootlearn.utils.RedisUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author 刘星宇
 * @Date 2020/10/5 19:50
 */
//@Api(tags = "学习springboot")
@RestController
public class DeptController {

    @Autowired
    private DepartmentMapper departmentMapper;

    private RedisUtil redisUtil;

//    @ApiOperation("获取全部的部门")
    @GetMapping("/getDepartments")
    public List<Department> getDepartments(){
        List<Department> departments = departmentMapper.getDepartments();
        for (Department d: departments) {
            System.out.println(d);
        }
        return departments;
    }

//    @ApiOperation("获取指定id的部门")
    @GetMapping("/getDepartment/{id}")
    public Department getDepartment(@ApiParam("部门id") @PathVariable("id") int id){
        return departmentMapper.getDepartment(id);
    }
}
